
package interfaz;

import javax.swing.JOptionPane;

public class VentanaNuevaPartida extends javax.swing.JDialog {
    private VentanaPrincipal vp;

    public VentanaNuevaPartida(java.awt.Frame parent, boolean modal) {
        super(parent, modal);
        initComponents();
        vp = (VentanaPrincipal)parent;
        this.setLocationRelativeTo(null);
    }

    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jrbNuevo = new javax.swing.JRadioButton();
        jrbConectarse = new javax.swing.JRadioButton();
        jbAceptar = new javax.swing.JButton();
        jLabel1 = new javax.swing.JLabel();

        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
        setTitle("Selección Partida");

        jrbNuevo.setSelected(true);
        jrbNuevo.setText("Iniciar Nueva Partida");
        jrbNuevo.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jrbNuevoActionPerformed(evt);
            }
        });

        jrbConectarse.setText("Conectarse a una Partida");
        jrbConectarse.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jrbConectarseActionPerformed(evt);
            }
        });

        jbAceptar.setText("Aceptar");
        jbAceptar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jbAceptarActionPerformed(evt);
            }
        });

        jLabel1.setText("Bienvenido al asistente de TEG. Elija:");

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                        .addComponent(jrbConectarse)
                        .addComponent(jrbNuevo)
                        .addGroup(layout.createSequentialGroup()
                            .addGap(32, 32, 32)
                            .addComponent(jbAceptar)))
                    .addComponent(jLabel1))
                .addContainerGap(42, Short.MAX_VALUE))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jLabel1)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 26, Short.MAX_VALUE)
                .addComponent(jrbNuevo)
                .addGap(18, 18, 18)
                .addComponent(jrbConectarse)
                .addGap(18, 18, 18)
                .addComponent(jbAceptar)
                .addContainerGap())
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void jrbNuevoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jrbNuevoActionPerformed
        jrbNuevo.setSelected(true);
        jrbConectarse.setSelected(false);
    }//GEN-LAST:event_jrbNuevoActionPerformed

    private void jrbConectarseActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jrbConectarseActionPerformed
        jrbConectarse.setSelected(true);
        jrbNuevo.setSelected(false);
    }//GEN-LAST:event_jrbConectarseActionPerformed

    private void jbAceptarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jbAceptarActionPerformed
        if(jrbNuevo.isSelected()){
            JOptionPane.showMessageDialog(null, "Usted es el administrador de la partida", "Atención", JOptionPane.INFORMATION_MESSAGE);
            new VentanaSeleccionColor(vp, true).setVisible(true);
        }else{
            new VentanaCliente(vp, true).setVisible(true);
        }
        this.dispose();
    }//GEN-LAST:event_jbAceptarActionPerformed

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JLabel jLabel1;
    private javax.swing.JButton jbAceptar;
    private javax.swing.JRadioButton jrbConectarse;
    private javax.swing.JRadioButton jrbNuevo;
    // End of variables declaration//GEN-END:variables

}
